﻿<!DOCTYPE HTML>
<html>
<head>
    <title>fly.box 企业网盘</title>
    <link href="themes/box-default/common.css" rel="stylesheet" type="text/css" />
    <link href="themes/box-default/login.css" rel="stylesheet" type="text/css" />
    <script src="../fly.common/fly/fly.js" type="text/javascript"></script>
    <script src="common/common.js" type="text/javascript"></script>
    <script src="../fly.common/fly.ui/plugins/input/empty-box.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            var accountBox = new $.ui.EmptyBox("#account-box input");
            var pwdBox = new $.ui.EmptyBox('#password')
            var btnLogin = $("#login"), btnForget = $('#forget-pwd');
            var messageBox = $("#message-box");
            $.doc.click(function () {
                messageBox.hideHandle = setTimeout(function () {
                    messageBox.hide()
                }, 5000);
            });

            function showMessage(msg) {
                messageBox.html(msg)
                clearTimeout(messageBox.hideHandle)
                messageBox.fadeIn();
            }

            function validate(vPwd) {
                if (!accountBox.value())
                    return '请输入帐号/手机/邮箱'
                if (vPwd && !pwdBox.value())
                    return '请输入密码';
            }

            btnLogin.click(function () {
                clearTimeout(messageBox.hideHandle)
                messageBox.hide()
                var msg = validate(true)
                if (msg) {
                    showMessage(msg);
                    return false
                }

                btnLogin.disable()
                $.post({
                    url: "do/login.ashx",
                    data: {
                        account: accountBox.value(),
                        password: pwdBox.value(),
                        "auto-login": $("#auto-login").attr("checked")
                    },
                    success: function (result) {
                        if (result.success)
                            window.location.href = result.data == true ? "o-index.htm" : "index.htm";
                        else {
                            showMessage(result.msg);
                        }
                        btnLogin.enable()
                    },
                    onError: function (err, xhr) {
                        btnLogin.enable();
                    }
                })
                return false;
            });

            btnForget.click(function () {
                clearTimeout(messageBox.hideHandle)
                messageBox.hide()
                var msg = validate()
                if (msg) {
                    showMessage(msg);
                    return false
                }
                btnForget.disable()
                $.post({
                    url: "do/applyResetPassword.ashx",
                    data: {
                        account: accountBox.value()
                    },
                    success: function (result) {
                        if (result.success) {
                            var msg = '已将密码重置连接发送至你的邮箱“{0}”，请在48小时内进入邮箱按提示重设密码。'.format(result.data)
                            showMessage(msg);
                            alert(msg);
                            alert(msg);
                        }
                        else {
                            showMessage(result.msg);
                        }
                        btnForget.enable();
                    }
                })
                return false;
            })
        })
    </script>
</head>
<body>
    <div id="banner">
    </div>
    <div id="center-content">
        <div id="feature-box">
        </div>
        <div id="login-box">
            <form>
            <div id="message-box">
            </div>
            <span id="account-box" class="empty-box">
                <input name="account" emptyvalue="请输入帐号/手机/邮箱" />
            </span><span id="password-box" class="empty-box">
                <label for="password">
                    请输入您的密码</label>
                <input id="password" name="password" type="password" cssbox='#password-box' title="请输入您的密码">
            </span>
            <div id="login-buttons">
                <button type="submit" id="login">
                    登录</button>
            </div>
            <div id="login-other">
                <input type="checkbox" name="auto-login" id="auto-login" /><label for="auto-login">自动登录</label>
                <a href="#" class="a-button" id="forget-pwd">忘记密码</a> <!--<a href="#" class="a-button">立即注册</a>-->
            </div>
            </form>
        </div>
    </div>
    <div id="footer">
        <div id="right-box">
            <div></div>
            <div><!--<a href='' target='_blank' ></a>-->fly.box 企业网盘 © 2012-2013 </div>
        </div>
    </div>
</body>
</html>
